package com.lkm.app_ui;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;

import com.lkm.app_ui.help.RootCommand;



public class InstallReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {

        
        if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")||intent.getAction().equals("android.intent.action.PACKAGE_REPLACED")) {

            String packageName_ = intent.getDataString();//package:ca.zgrs.clipper
            String[] ss = packageName_.split(":");
            String packageName = ss[ss.length-1];

            System.out.println("===== InstallReceiver"+packageName);


            

//            BootReceiver.startApp(AppConst.getApplication(),packageName);//; AppConst.getApplication().getPackageName());
            try {
                new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        BootReceiver.startApp(AppConst.getApplication(), packageName);
                    }
                }, 1500);
            }catch (Exception e){
                BootReceiver.startApp(AppConst.getApplication(),packageName);//; AppConst.getApplication().getPackageName());
            }

        }



    }
}